package stacks


type MinStack struct {
	stack []int
	minStack []int
}

func Constructor() MinStack {
	return MinStack{stack: []int{}, minStack: []int{}}
}

func (t *MinStack) Push(val int) {
	t.stack = append(t.stack, val)
	top := t.minStack[len(t.minStack) - 1]
	t.minStack = append(t.minStack, min(top, val))
}

func (t *MinStack) Pop() {
	t.stack = t.stack[:len(t.stack) - 1]
	t.minStack = t.minStack[:len(t.minStack) - 1]
}

func (t *MinStack) Top() int {
	return t.stack[len(t.stack) - 1]
}

func (t *MinStack) GetMin() int {
	return t.minStack[len(t.minStack) - 1]
}
